package org.meb.lotrlcg.db.util;

import java.text.Normalizer;
import java.text.Normalizer.Form;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Utils {

	private static final Logger log = LoggerFactory.getLogger(Utils.class);

	public static String toTechName(String name) {
		String techName = Normalizer.normalize(name, Form.NFD).replaceAll("[^\\p{ASCII}]", "");
		techName = techName.replaceAll("[^\\p{Alpha} \\-]", "").replace(' ', '-')
				.replaceAll("\\-+", "-");
		techName = StringUtils.removeStart(techName, "-");
		techName = StringUtils.removeEnd(techName, "-");
		techName = techName.toLowerCase().trim();
		log.debug("toTechName(): name: {}, techName: {}", name, techName);
		return techName;
	}
}
